﻿using System.Collections;
using FlowCanvas;
using FlowCanvas.Nodes;
using NodeCanvas.Framework;
using ParadoxNotion.Design;
using UnityEngine;
using Yoozoo.Gameplay.Liberty.AI;

namespace Yoozoo.Gameplay.Liberty.Nodes
{
    [Category("Ggame")][Description("生成Npc全参数设置")]
    public class AddBTNpcEx : LatentActionNodeBase
    {
        private int uniqueId = -1;
        public override bool allowRoutineQueueing { get { return false; } }

        public IEnumerator Invoke(string pointName, AIBirthData birthData)
        {
            yield return new WaitForOneFrame();
            if (!string.IsNullOrEmpty(pointName))
            {
                var point = BlueprintUtils.GetBlueprintPoint(pointName);
                if (point!=null)
                {
                    birthData.position = point.position;
                    birthData.forward = point.forward;
                }
            }
            LibertyAIUtils.AddNpc(birthData);
        }
        
        protected override void OnRegisterDerivedPorts(FlowNode node)
        {
            var p0 = node.AddValueInput<string>("pointName");
            var p1 = node.AddValueInput<AIBirthData>("BirthData");
            node.AddFlowInput("In", (f) => { Begin(Invoke(p0.value, p1.value), f); });

        }
    }
}